EXECUTABLE := main 

LIBS := -L/usr/local/lib -lplayerc++ -L/usr/X11R6/lib -lX11 -lm -lpthread -lstdc++ -I /usr/include/boost/boost
INCLUDE = -I/usr/local/include/player-2.1 -I/usr/include  ./CFSQP/cfsqp.o -I /usr/include/boost/boost


#CFLAGS := -g -Wall -O3 -m486
#CFLAGS := -g -Wall -O3 
CFLAGS := -g -Wall -D_REENTRANT -DLinux
CXXFLAGS := $(CFLAGS)


RM-F := rm -f


SOURCE := $(wildcard *.c) $(wildcard *.cc)
OBJS := $(patsubst %.c,%.o,$(patsubst %.cc,%.o,$(SOURCE)))
DEPS := $(patsubst %.o,%.d,$(OBJS))
MISSING_DEPS := $(filter-out $(wildcard $(DEPS)),$(DEPS))
MISSING_DEPS_SOURCES := $(wildcard $(patsubst %.d,%.c,$(MISSING_DEPS)) \
$(patsubst %.d,%.cc,$(MISSING_DEPS)))

CPPFLAGS += -MD
CPPFLAGS += $(LIBS)
CPPFLAGS += $(INCLUDE)
CPPFLAGS += -ggdb
CPPFLAGS += -DDEBUGGA
.PHONY : everything deps objs clean veryclean rebuild

all : $(EXECUTABLE)

deps : $(DEPS)

objs : $(OBJS)

clean :
	@$(RM-F) *.o
	@$(RM-F) *.d

veryclean: clean
	@$(RM-F) $(EXECUTABLE) $(wildcard *~)

rebuild: veryclean everything

ifneq ($(MISSING_DEPS),)
$(MISSING_DEPS) :
	@$(RM-F) $(patsubst %.d,%.o,$@)
endif

-include $(DEPS)

$(EXECUTABLE) : $(OBJS)
	g++ $(INCLUDE) $(LIBS) -o  $(EXECUTABLE) $(OBJS) 

